package com.medical.Controller.user;

import com.medical.DTO.HealthDataDTO;
import com.medical.DTO.HealthDataPageDTO;
import com.medical.Service.HealthDataService;
import com.medical.result.PageResult;
import com.medical.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Tag(name = "用户健康数据管理")
public class HealthDataController {
    @Autowired
    private HealthDataService healthDataService;

    /*
     添加用户健康数据
     * @param healthDataDTO
     * @return
     */
    @PostMapping("/addHealthData")
    @Operation(summary = "添加用户健康数据")
    public Result addHealthData(@RequestBody HealthDataDTO healthDataDTO) {
        healthDataService.addHealthData(healthDataDTO);
        return Result.success();
    }

    /*
     删除用户健康数据
     * @param ids
     * @return
     */
    @DeleteMapping("/deleteHealthData/{ids}")
    @Operation(summary = "删除用户健康数据")
    public Result deleteHealthData(@PathVariable List<Integer> ids) {
        healthDataService.deleteHealthData(ids);
        return Result.success();
    }

    /*
     修改用户健康数据
     * @param healthDataDTO
     * @return
     */
    @PutMapping("/updateHealthData")
    @Operation(summary = "修改用户健康数据")
    public Result updateHealthData(@RequestBody HealthDataDTO healthDataDTO) {
        healthDataService.updateHealthData(healthDataDTO);
        return Result.success();
    }

    /*
     获取用户健康数据列表
     * @param healthDataDTO
     * @return
     */
    @GetMapping("/page")
    @Operation(summary = "获取用户健康数据列表")
    public Result getHealthDataList(HealthDataPageDTO healthDataPageDTO) {
       PageResult pageResult= healthDataService.page(healthDataPageDTO);
        return Result.success(pageResult);
    }

}
